$.ajax({
    type: "post",
    url: "/system/fuzMoKuai0",
    data: {},
    dataType: "json",
    success: function (r) {
        if (r!="null"){
            var u=""
            for (var i=0;i<r.length;i++){
                u+="<li>\n" +
                    "                <input type=\"checkbox\" name='first' value='"+r[i].module_id+"' />\n" +
                    "                <a href=\"javascript:void(0);\" id='y"+i+"' >"+r[i].module_rname+"</a>\n" +
                    "\n" +
                    "                <ul class=\"hidden\" id='x"+i+"'>" +
                    "</ul>\n" +
                    "            </li>"
            }
            $(".forminfo").html(u)


        }else {
            alert("暂时没有模块可以赋权!")
        }
    }
})

$.ajax({
    type: "post",
    url: "/system/fuzMoKuai1",
    data: {},
    dataType: "json",
    success: function (t) {
        var u=""
        for (var i=0;i<t.length;i++){
            u+="<li>\n" +
                "                        <input type=\"checkbox\" name='first1' value='"+t[i].module_id+"' />\n" +
                "                        <a href=\"../modules/moduleView.html\">"+t[i].module_rname+"</a>\n" +
                "                    </li>"
        }
        $("#x0").html(u)
    }
})
$.ajax({
    type: "post",
    url: "/system/fuzMoKuai2",
    data: {},
    dataType: "json",
    success: function (t) {
        var u=""
        for (var i=0;i<t.length;i++){
            u+="<li>\n" +
                "                        <input type=\"checkbox\" name='first2' value='"+t[i].module_id+"' />\n" +
                "                        <a href=\"../modules/moduleView.html\">"+t[i].module_rname+"</a>\n" +
                "                    </li>"
        }
        $("#x1").html(u)
    }
})
$.ajax({
    type: "post",
    url: "/system/fuzMoKuai3",
    data: {},
    dataType: "json",
    success: function (t) {
        var u=""
        for (var i=0;i<t.length;i++){
            u+="<li>\n" +
                "                        <input type=\"checkbox\" name='first3' value='"+t[i].module_id+"' />\n" +
                "                        <a href=\"../modules/moduleView.html\">"+t[i].module_rname+"</a>\n" +
                "                    </li>"
        }
        $("#x2").html(u)
    }
})
$.ajax({
    type: "post",
    url: "/system/fuzMoKuai4",
    data: {},
    dataType: "json",
    success: function (t) {
        var u=""
        for (var i=0;i<t.length;i++){
            u+="<li>\n" +
                "                        <input type=\"checkbox\" name='first4' value='"+t[i].module_id+"' />\n" +
                "                        <a href=\"../modules/moduleView.html\">"+t[i].module_rname+"</a>\n" +
                "                    </li>"
        }
        $("#x3").html(u)
    }
})
$.ajax({
    type: "post",
    url: "/system/fuzMoKuai5",
    data: {},
    dataType: "json",
    success: function (t) {
        var u=""
        for (var i=0;i<t.length;i++){
            u+="<li>\n" +
                "                        <input type=\"checkbox\" name='first5' value='"+t[i].module_id+"' />\n" +
                "                        <a href=\"../modules/moduleView.html\">"+t[i].module_rname+"</a>\n" +
                "                    </li>"
        }
        $("#x4").html(u)
    }
})

$("#submit").click(function () {
    var chk_value=[]
    var checkbox =$("input[name='first']:checkbox[checked]").each(function(){
        chk_value.push($(this).val());
    });
    var checkbox =$("input[name='first1']:checkbox[checked]").each(function(){
        chk_value.push($(this).val());
    });
    var checkbox =$("input[name='first2']:checkbox[checked]").each(function(){
        chk_value.push($(this).val());
    });
    var checkbox =$("input[name='first3']:checkbox[checked]").each(function(){
        chk_value.push($(this).val());
    });
    var checkbox =$("input[name='first4']:checkbox[checked]").each(function(){
        chk_value.push($(this).val());
    });
    var checkbox =$("input[name='first5']:checkbox[checked]").each(function(){
        chk_value.push($(this).val());
    });
    $.ajax({
        type: "post",
        url: "/system/fuquan",
        data: JSON.stringify(chk_value),
        contentType:"application/json",
        dataType: "json",
        success: function (r) {
            if (r=="true"){
                alert("赋权成功!")
            }else {
                alert("赋权失败！")
            }
        }
    })
})

//
// $(function(){
//     $("#treeMenu").children("li").children(":checkbox").click(function(){
//         var flag = $(this).attr("checked");
//         $(this).siblings("ul").show();
//         $(this).siblings("ul").children("li").children(":checkbox").attr("checked", flag);
//     }).siblings("a").click(function(){
//         $(this).siblings("ul").toggle();
//     });
// });